package com.loopy.servlet.homework;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet(name = "MyPayServlet", value = "/my-pay")
public class MyPayServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String num = request.getParameter("num");
        String money = request.getParameter("money");
        System.out.println("用户编号："+num);
        System.out.println("支付金额："+money);

        int v =WebUtils.parseInt(money);
        if(v>100){
//            RequestDispatcher requestDispatcher = request.getRequestDispatcher("/payOk.html");
//            requestDispatcher.forward(request,response);
            response.sendRedirect("/ServletHomework/payOk.html");
        }else {
//            RequestDispatcher requestDispatcher = request.getRequestDispatcher("/pay.html");
//            requestDispatcher.forward(request,response);
            response.sendRedirect("/ServletHomework/pay.html");
        }

    }
}
